//
//  WKAlbumModel.m
//  Version1.0_RectiveCocoa
//
//  Created by ChiCo on 2018/1/30.
//  Copyright © 2018年 吴可高. All rights reserved.
//

#import "WKAlbumModel.h"
#import "WKAlbumManger.h"
#import "WKAssetModel.h"

@implementation WKAlbumModel

- (void)setResult:(id)result needFetchAssets:(BOOL)needFetchAssets {
    _result = result;
    if (needFetchAssets) {
        [[WKAlbumManger manager] getAssetsFromFetchResult:result completion:^(NSArray<WKAlbumModel *> *models) {
            _models = models;
            if (_selectedModels) {
                [self checkSelectedModels];
            }
        }];
    }
}

- (void)setSelectedModels:(NSArray *)selectedModels {
    _selectedModels = selectedModels;
    if (_models) {
        [self checkSelectedModels];
    }
}

- (void)checkSelectedModels {
    self.selectedCount = 0;
    NSMutableArray *selectedAssets = [NSMutableArray array];
    for (WKAssetModel *model in _selectedModels) {
        [selectedAssets addObject:model.asset];
    }
//    for (WKAssetModel *model in _models) {
//        if ([[WKAlbumManger manager] isAssetsArray:selectedAssets containAsset:model.asset]) {
//            self.selectedCount ++;
//        }
//    }
}

- (NSString *)name {
    if (_name) {
        return _name;
    }
    return @"";
}

@end
